import { createRouter, createWebHistory } from 'vue-router'
import list from '../views/list.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      alias: '/xyz',
      component: list
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/list',
      meta: {
        title: '商品列表'
      },
      component: () => import('../views/list.vue')
    },
    {
      path: '/product/:id(\\d+)',
      meta: {
        title: '商品详情'
      },
      component: () => import('../views/product.vue')
    },

    {
      path: '/cart',
      meta: {
        title: '购物车'
      },
      component: () => import('../views/cart.vue')
    },
    {
      path: '/:XYZ',
      redirect: '/list'
    }

  ]
})

export default router
